﻿using System.IO;
using System.IO.Compression;
using System.Web;

namespace Nana.Web.Compressing
{
  public sealed class DeflateFilterFactory
    : ResponseFilterFactory
  {
    public DeflateFilterFactory() { }

    //[FactoryInstance]
    //public static DeflateFilterFactory Instance { get; private set; }

    //static DeflateFilterFactory()
    //{
    //  Instance = new DeflateFilterFactory();
    //}

    public override void SetupHeaders(HttpContext context)
    {
      context.Response.AppendHeader("Content-Encoding", "deflate");
    }

    public override Stream CreateFilter(Stream baseFilter)
    {
      return new DeflateStream(baseFilter, CompressionMode.Compress);
    }
  }
}
